<template>
  <div>
    <el-descriptions
      v-if="taskInfo['task_type_id']===8 && taskInfo['sjpq_info']['task_code']"
      title="数据爬取-视频"
      :column="1"
      border
    >
      <el-descriptions-item label="任务编号:">{{ taskInfo['sjpq_info']['task_code'] }}</el-descriptions-item>
      <el-descriptions-item label="指定账号:">{{ taskInfo['sjpq_info']['account_id'] }}</el-descriptions-item>
      <el-descriptions-item label="视频关键字	:">{{ taskInfo['sjpq_info']['video_keywords'] }}</el-descriptions-item>
      <el-descriptions-item label="评论关键字:">{{ taskInfo['sjpq_info']['comment_keywords'] }}</el-descriptions-item>
      <el-descriptions-item label="筛选时间:">{{ taskInfo['sjpq_info']['select_time'] }} 天</el-descriptions-item>
      <el-descriptions-item label="type:">{{ taskInfo['sjpq_info']['type'] == 1 ? '账号ID抓取' : '视频关键字抓取' }}</el-descriptions-item>

    </el-descriptions>

    <el-descriptions
      v-if="taskInfo['task_type_id']===8 && taskInfo['sjpqzb_info']['task_code']"
      title="数据爬取-直播间"
      :column="1"
      border
    >
      <el-descriptions-item label="任务编号:">{{ taskInfo['sjpqzb_info']['task_code'] }}</el-descriptions-item>
      <el-descriptions-item label="直播间ID:">{{ taskInfo['sjpqzb_info']['live_room_id'] }}</el-descriptions-item>
      <el-descriptions-item label="直播关键字	:">{{ taskInfo['sjpqzb_info']['live_keywords'] }}</el-descriptions-item>
      <el-descriptions-item label="直播间飘屏评论关键字:">{{ taskInfo['sjpqzb_info']['live_piaoping_review'] }}</el-descriptions-item>
      <el-descriptions-item label="停留时长:">{{ taskInfo['sjpqzb_info']['stay_duration'] }} 分钟</el-descriptions-item>

    </el-descriptions>

    <el-descriptions
      v-if="taskInfo['task_type_id']===9"
      title="一键私信"
      :column="1"
      border
    >
      <el-descriptions-item label="私信ID列表:">{{ taskInfo['yjsx_info']['task_code'] }}</el-descriptions-item>
      <el-descriptions-item label="私信内容:">{{ taskInfo['yjsx_info']['tomessages'] }}</el-descriptions-item>
      <el-descriptions-item label="抖音账号列表:">{{ taskInfo['yjsx_info']['accounts'] }}</el-descriptions-item>
      <el-descriptions-item label="私信次数:">{{ taskInfo['yjsx_info']['private_letters_number'] }}</el-descriptions-item>
    </el-descriptions>

    <el-descriptions
      v-if="taskInfo['task_type_id']===10"
      title="上号"
      :column="1"
      border
    >
      <el-descriptions-item label="任务编号:">{{ taskInfo['sh_info']['task_code'] }}</el-descriptions-item>
      <el-descriptions-item label="私信内容:">{{ taskInfo['sh_info']['equipment_ids'] }}</el-descriptions-item>
    </el-descriptions>

    <el-descriptions
      v-if="taskInfo['task_type_id']===11"
      title="一键@"
      :column="1"
      border
    >
      <el-descriptions-item label="任务编号:">{{ taskInfo['yjat_info']['task_code'] }}</el-descriptions-item>
      <el-descriptions-item label="评论内容:">{{ taskInfo['yjat_info']['equipment_ids'] }}</el-descriptions-item>
      <el-descriptions-item label="抖音账号列表:">{{ taskInfo['yjat_info']['accounts'] }}</el-descriptions-item>
      <el-descriptions-item label="视频账号ID:">{{ taskInfo['yjat_info']['video_account_id'] }}</el-descriptions-item>
      <el-descriptions-item label="视频位置:">{{ taskInfo['yjat_info']['video_location'] }}</el-descriptions-item>
    </el-descriptions>

    <el-descriptions
      v-if="taskInfo['task_type_id']===12"
      title="一键重置"
      :column="1"
      border
    >
      <el-descriptions-item label="任务编号:">{{ taskInfo['yjcz_info']['task_code'] }}</el-descriptions-item>
      <el-descriptions-item label="重置选项:">{{ taskInfo['yjcz_info']['reset_options'] == 1 ? '重置设备' : '重启设备' }}</el-descriptions-item>
    </el-descriptions>

    <el-descriptions
      v-if="taskInfo['task_type_id']===13"
      title="一键重置"
      :column="1"
      border
    >
      <el-descriptions-item label="任务编号:">{{ taskInfo['yjcz_info']['task_code'] }}</el-descriptions-item>
      <el-descriptions-item label="是否清空通讯录:">{{ taskInfo['yjcz_info']['reset_options'] == 1 ? '是' : '否' }}</el-descriptions-item>
    </el-descriptions>

    <!-- 列表 -->
    <el-table v-if="taskInfo['task_type_id'] === 8 || taskInfo['task_type_id'] === 9" v-loading="loading" :data="datas" :height="height" style="width: 100%">
      <el-table-column prop="nickname" label="昵称" min-width="100" sortable="custom" />
      <el-table-column prop="account_id" label="账号id" min-width="100" sortable="custom" show-overflow-tooltip />
      <el-table-column prop="comment" label="评论" min-width="100" sortable="custom" show-overflow-tooltip />
      <el-table-column prop="date" label="时间" min-width="100" sortable="custom" show-overflow-tooltip />
      <el-table-column prop="works_num" label="作品数" min-width="100" sortable="custom" />
      <el-table-column prop="supports_num" label="获赞数" min-width="100" sortable="custom" />
      <el-table-column prop="concerns_num" label="关注数" min-width="105" sortable="custom" />
      <el-table-column prop="fans_num" label="粉丝数" min-width="105" sortable="custom" />
      <el-table-column prop="like_num" label="喜欢" min-width="105" sortable="custom" />
    </el-table>

    <!-- 分页 -->
    <pagination
      v-show="count > 0"
      :total="count"
      :page.sync="query.page"
      :limit.sync="query['page_size']"
      @pagination="list"
    />
  </div>
</template>

<script>
import {
  list
} from '@/api/admin/task-sjpq'
import {
  info
} from '@/api/admin/tasks.js'
import pagination from '@/components/Pagination'

export default {
  name: 'TaskDataDetail',
  components: {
    pagination
  },
  props: {
    taskData: {
      type: Array,
      default: () => ([{
        a: 1
      },
      {
        b: 2
      }
      ])
    }
  },
  data() {
    return {
      loading: false,
      datas: [],
      height: 750,

      taskInfo: {},
      count: 0,
      query: {
        page: 1,
        'page_size': 10
      }
    }
  },
  created() {
    console.log('created:', this.taskData)
    this.list()
  },
  methods: {
    taskinfo() {
      const query = {
        'id': this.taskData['id']
      }
      info(query).then(res => {
        console.log(res.data)
        this.taskInfo = res.data
      }).catch(() => {

      })
    },
    // 列表
    list() {
      this.loading = true
      this.taskinfo()
      this.query.field = 'task_code'
      this.query.keyword = this.taskData['task_code']

      list(this.query).then(res => {
        this.datas = res.data.list
        this.count = res.data['page_total'] * this.query['page_size']
        this.loading = false
      }).catch(() => {
        this.loading = false
      })
    },
    addTime(m) {
      return m < 10 ? '0' + m : m
    },
    // 时间转换
    getTime(time) {
      var times = new Date(time * 1000)
      // shijianchuo是整数，否则要parseInt转换
      var y = times.getFullYear()
      var m = times.getMonth() + 1
      var d = times.getDate()
      var h = times.getHours()
      var mm = times.getMinutes()
      var s = times.getSeconds()
      console.log(y + '-' + this.addTime(m) + '-' + this.addTime(d) + ' ' + this.addTime(h) + ':' + this.addTime(mm) + ':' +
                    this
                      .addTime(
                        s))
      return y + '-' + this.addTime(m) + '-' + this.addTime(d) + ' ' + this.addTime(h) + ':' + this.addTime(mm) + ':' + this
        .addTime(
          s)
    }
  }
}
</script>

<style>
</style>
